package com.lzx.iteam.bean.aidl;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Arrays;

/**
 * Created by Megan on 16/2/22.
 */
public class CustomTokenIQ implements Parcelable{

    public static final Parcelable.Creator<CustomTokenIQ> CREATOR = new Parcelable.Creator<CustomTokenIQ>() {

        @Override
        public CustomTokenIQ createFromParcel(Parcel source) {
            return new CustomTokenIQ(source);
        }

        @Override
        public CustomTokenIQ[] newArray(int size) {
            return new CustomTokenIQ[size];
        }
    };

    private String uuid;
    private String token;
    private String key;
    private String grp;
    private String msgId;
    private  String soundFile;
    private byte[] imageFile;
    private ChatMoreMsg chatMoreMsg=new ChatMoreMsg();


    public CustomTokenIQ() {
    }

    public CustomTokenIQ(Parcel source) {
        readFromParcel(source);
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getGrp() {
        return grp;
    }

    public void setGrp(String grp) {
        this.grp = grp;
    }

    public String getMsgId() {
        return msgId;
    }

    public void setMsgId(String msgId) {
        this.msgId = msgId;
    }


    public String getSoundFile() {
        return soundFile;
    }

    public void setSoundFile(String soundFile) {
        this.soundFile = soundFile;
    }

    public byte[] getImageFile() {
        return imageFile;
    }

    public void setImageFile(byte[] imageFile) {
        this.imageFile = imageFile;
    }


    public ChatMoreMsg getChatMoreMsg() {
        return chatMoreMsg;
    }

    public void setChatMoreMsg(ChatMoreMsg chatMoreMsg) {
        this.chatMoreMsg = chatMoreMsg;
    }

    @Override
    public String toString() {
        return "CustomTokenIQ{" +
                "uuid='" + uuid + '\'' +
                ", token='" + token + '\'' +
                ", key='" + key + '\'' +
                ", grp='" + grp + '\'' +
                ", msgId='" + msgId + '\'' +
                ", soundFile='" + soundFile + '\'' +
                ", imageFile=" + Arrays.toString(imageFile) +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(this.uuid);
        parcel.writeString(this.token);
        parcel.writeString(this.key);
        parcel.writeString(this.grp);
        parcel.writeString(this.msgId);
        parcel.writeString(this.soundFile);
        parcel.writeParcelable(this.chatMoreMsg, i);

        if(imageFile==null){
            parcel.writeInt(0);
        }else{
            parcel.writeInt(imageFile.length);
        }
        //如果数组为空，就可以不写
        if(imageFile != null) {
            parcel.writeByteArray(this.imageFile);
        }


    }

    public void readFromParcel(Parcel source) {
        uuid = source.readString();
        token = source.readString();
        key = source.readString();
        grp = source.readString();
        msgId = source.readString();
        soundFile = source.readString();
        chatMoreMsg = source.readParcelable(ChatMoreMsg.class.getClassLoader());

        int length=source.readInt();
        if(length>0){
            imageFile=new byte[length];
            source.readByteArray(imageFile);
        }

    }
}
